package com.aspose.cells;

import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.util.Enumeration;
import javax.security.cert.X509Certificate;

public class DigitalSignature {
   private PrivateKey a;
   private KeyStore b;
   private String c;
   private DateTime d;
   private boolean e = true;

   public DigitalSignature(KeyStore Certificate, String privateKeyPassword, String Comments, DateTime SignTime) {
      this.b = Certificate;
      this.c = Comments;
      this.d = SignTime;
      this.a = this.a(privateKeyPassword);
   }

   public DigitalSignature(X509Certificate cert, String comments, DateTime signtime, boolean result) {
      this.c = comments;
      this.d = signtime;
      this.e = result;
   }

   public KeyStore getCertificate() {
      return this.b;
   }

   public void setCertificate(KeyStore value) {
      this.b = value;
   }

   byte[] a() throws Exception {
      Enumeration var1 = this.getCertificate().aliases();
      Object var2 = null;

      while(true) {
         Certificate[] var3;
         do {
            do {
               if (!var1.hasMoreElements()) {
                  return null;
               }

               var3 = this.getCertificate().getCertificateChain((String)var1.nextElement());
            } while(var3 == null);
         } while(var3.length == 0);

         for(int var5 = 0; var5 < var3.length; ++var5) {
            java.security.cert.X509Certificate var6 = (java.security.cert.X509Certificate)var3[var5];
            boolean[] var4 = var6.getKeyUsage();
            if (var4 != null && var4.length != 0 && var4[0]) {
               return var6.getEncoded();
            }
         }
      }
   }

   PrivateKey b() {
      return this.a;
   }

   private PrivateKey a(String var1) {
      PrivateKey var2 = null;

      String var4;
      try {
         for(Enumeration var3 = this.getCertificate().aliases(); var3.hasMoreElements(); var2 = (PrivateKey)this.getCertificate().getKey(var4, var1.toCharArray())) {
            var4 = (String)var3.nextElement();
         }
      } catch (Exception var5) {
         ;
      }

      return var2;
   }

   public String getComments() {
      return this.c;
   }

   public void setComments(String value) {
      this.setComments(value);
   }

   public DateTime getSignTime() {
      return this.d;
   }

   public void setSignTime(DateTime value) {
      this.d = value;
   }

   public boolean isValid() {
      return this.e;
   }
}
